package com.core.log;

import org.apache.log4j.Logger;
import org.apache.log4j.PropertyConfigurator;

public class Log {
	private static Logger log ;
	private static Log l ;
	static String logProject="Debug";
	static{
		synchronized(Log.class){
			PropertyConfigurator.configure("E:/Java/workspace/Rule/config/log4j.properties");
			log = Logger.getLogger("MyLog");
			System.out.println("static ...");
		}
	}
	private Log(){}
	public static synchronized Log getInstance(){
		if(l==null)
			l = new Log();
		return l;
	}
	public void setConfigurator(String url){
	
		PropertyConfigurator.configure(url);
	}

	public static void debug(Object msg){
		Exception e = new Exception();
        StackTraceElement trace1 = e.getStackTrace()[1];
        
        log.debug("["+logProject+"] " + trace1 + " - "+msg);
	}
	
	public static void info(Object msg){
		Exception e = new Exception();
        StackTraceElement trace = e.getStackTrace()[1];
        log.info("[Info] " + trace + " - " + msg);
	}
	
	public static void error(Object msg){
		 Exception e = new Exception();
	     StackTraceElement trace = e.getStackTrace()[1];
	     log.error("[Error] " + trace + " - " + msg);
	}
	
	public static void warn(Object msg){
		Exception e = new Exception();
        StackTraceElement trace = e.getStackTrace()[1];
        log.warn("[WARN] " + trace + " - " + msg);
		
	}
	
	
	
	
	public static void main(String[] args) {

		Log.debug("dddddd");

	}
	
}
